<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>04_JS运算符</title>
</head>
<body>
<script>
    console.log(6/3);//2
    console.log(3/2);//1.5

    console.log(3>10);//false
    console.log(3>'10');//false Number('10')=>10 3>10?
    console.log('3'>10);//false
    console.log('奇'>'字');//true 都是字符串比较的是字符的编码值
    console.log('奇'.charCodeAt());//查看字符的编码值,默认值为0,查看第一个字符的编码值
    console.log('字'.charCodeAt());
    console.log('3'>'10');//51>49=true
    console.log('3'.charCodeAt());//51
    console.log('13'.charCodeAt(0));//第一个位置,1的编码为49
    console.log('13'.charCodeAt(1));//第二个位置,3的编码为51

    let a = 1;
    let b = true;
    //松散比较运算符会比较左右两边的值,严格比较运算符会比较类型,类型相同再比较值
    console.log(a == b);//1==Number(true) 值都是1 结果为true
    console.log(a === b);//number != boolean,结果为false

    //三元运算符
    //1 ? 2 : 3
    let c = 0;
    console.log(c == 0 ? 'YES' : 'NO');// 'YES'
    console.log((c = 0) ? 'YES' : 'NO');//  'NO'
    console.log(c);
    console.log(c ? 'YES' : 'NO');//'YES'
</script>
</body>
</html>